package com.thesis.client;

import java.util.ArrayList;



import com.thesis.object.ListDishType;
import com.thesis.client.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.BaseAdapter;
import android.widget.TextView;

public class FoodTypeAdapter extends BaseAdapter {

	private Context context;
    private int layoutResourceId;   
    ListDishType listType ;
    public FoodTypeAdapter(Context context, int layoutResourceId, ListDishType listType) {
        
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.listType = listType;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        RegardingTypeHolder holder = null;
       
        if(row == null)
        {
            LayoutInflater inflater = ((Activity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);
           
            holder = new RegardingTypeHolder();
            holder.textName=(TextView)row.findViewById(R.id.item_foodtype_tv);
            row.setTag(holder);
        }
        else
        {
            holder = (RegardingTypeHolder)row.getTag();
        }
       
        
        holder.textName.setText(listType.getInstance().getListDishTypes().get(position).getName());
        return row;
       
    }
   
    static class RegardingTypeHolder
    {
        
        TextView textName;
    }

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listType.getInstance().getListDishTypes().size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
}

